#include "adder2.h"

Adder::Adder()
{
	/* 成员变量初始化，并将其挂靠到父窗口this */
	add = new QLineEdit(this);
	added = new QLineEdit(this);
	res = new QLineEdit(this);
	oper = new QLabel("+",this);
	equ = new QPushButton("=",this);

	/* 调整成员变量位置 */
	this->resize(500,300);
	add->move(50,100);
	oper->move(200,100);
	added->move(300,100);
	equ->move(150,200);
	res->move(300,200);
	QObject::connect(equ, SIGNAL(clicked()),
		this,  SLOT(getRes()));	
};

Adder::~Adder()
{
	delete(add);
	delete(added);
	delete(res);
	delete(oper);
	delete(equ);
};

void Adder::getRes()
{
/*
	QString add1 = add->text();
	QString add2 = added->text();
	double sum = add1.toDouble() + add2.toDouble();
	add1 = QString::number(add1,'g',16);
*/	
	res->setText(QString::number(add->text().toDouble() + 
			added->text().toDouble(),'g',16));
};
